package plugins.GNotify;

import catchup.Main;
import java.io.FileNotFoundException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.gnome.gdk.Pixbuf;
import org.gnome.gtk.Gtk;
import org.gnome.gtk.StatusIcon;
import org.gnome.notify.Notification;
import org.gnome.notify.Notify;
import plugins.NotifyPlugin;

/**
 *
 * @author pieterc
 */
public class GnomeNotifyPlugin implements NotifyPlugin {

    public GnomeNotifyPlugin() {
        Gtk.init(null);
        Notify.init("Catchup v" + Main.version);
    }

    public void onNewMessages(int count) {
        if (count > 0) {
            Pixbuf p = null;
            try {
                p = new Pixbuf("/home/pieterc/catchup/catchup/catchup.png");
            } catch (FileNotFoundException ex) {
                Logger.getLogger(GnomeNotifyPlugin.class.getName()).log(Level.SEVERE, null, ex);
            }
            Notification n = new Notification("New messages", "You got " + count + " new messages in catchup", "catchup.png", new StatusIcon(p));
            n.show();
        }


    }

    public void onNewMessage(String s) {
    }
}
